<?php

namespace App\Command\Tools;

use App\Service\DictConstant;
use App\Service\DictGenerate;
use EchoPHP\Console\Command;

class GenerateDicts extends Command {

    protected $signature = "tools:generateDicts {debug? : 调试模式请输入1,默认关闭}";
    protected $description = '从.php生成INI数据字典';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct() {
        parent::__construct();
    }

    /*
     * 生成过程
     */
    public function handle() {
        $generator = new DictGenerate;
        $generator->debug = $this->argument('debug') == 1 ? true : false;
        $list = [
            DictConstant::DD_PROVINCE,
            DictConstant::DD_CITY,
            DictConstant::DD_COUNTY,
            DictConstant::DD_CITY_COUNTY,
            DictConstant::DD_FUNCTYPE,
            DictConstant::DD_FUNCTYPE_WITHPARENT,
            DictConstant::DD_GENDER,
            DictConstant::DD_MARRIAGE,
            DictConstant::DD_POLITICS,
            DictConstant::DD_DEGREE,
            DictConstant::DD_INDUSTRY,
            DictConstant::DD_MAJOR,
            DictConstant::DD_CERTIFICATION,
            DictConstant::DD_SKILL,
            DictConstant::DD_SKILL_LEVEL,
            DictConstant::DD_CURRENT_SITUATION,
            DictConstant::DD_JOB_TERM,
            DictConstant::DD_JOB_AREA,
            DictConstant::DD_MONTHLY_SALARY,
            DictConstant::DD_ANNUAL_SALARY,
            DictConstant::DD_NEW_JOB_ENTRY_TIME,
            DictConstant::DD_OTHER_INFO_TYPE,
            DictConstant::DD_COMPANY_SIZE,
            DictConstant::DD_COMPANY_TYPE,
            DictConstant::DD_ID_TYPE,
            DictConstant::DD_CONTACT_TYPE,
            DictConstant::DD_RESUME_TAG,
        ];
        try {
            foreach ($list as $item) {
                $generator->generate($item);
            }
        } catch (Exception $e) {
            $this->output->error('字典' . $item . '生成失败：' . $e->getMessage());
        }
        $this->output->success('字典生成完毕');
    }
}